import Big from 'big.js';

export const calcFn = {
	add(...args) {
		const arg = Array.from(args);
		return (
			arg
				.reduce((total, num) => {
					return new Big(total).plus(new Big(num));
				})
				.toString() * 1
		);
	},
	sub(...args) {
		const arg = Array.from(args);
		return (
			arg
				.reduce((total, num) => {
					return new Big(total).minus(new Big(num));
				})
				.toString() * 1
		);
	},
	mul(...args) {
		const arg = Array.from(args);
		return (
			arg
				.reduce((total, num) => {
					return new Big(total).times(new Big(num));
				})
				.toString() * 1
		);
	},
	divide(...args) {
		const arg = Array.from(args);
		return (
			arg
				.reduce((total, num) => {
					return new Big(total).div(new Big(num));
				})
				.toString() * 1
		);
	},
};
